﻿Imports System.Data.SqlClient

Public Class frmDangNhap

    Private Sub frmDangNhap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      
    End Sub

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Dim conn As New SqlConnection("Data Source=Zerosara-pc;Initial Catalog=QLTHUENHA;Integrated Security=True")
        Dim sqlapda = New SqlDataAdapter("SELECT * from NGUOIDUNG where username='" & txtTenDangNhap.Text & "' and pass ='" & txtMatKhau.Text & "'", conn)
        Dim tb As New DataTable()
        Try
            conn.Open()
            sqlapda.Fill(tb)
            conn.Close()

        Catch ex As Exception

        End Try

        If (tb.Rows.Count > 0) Then
            Dim f As New Home()
            f.Show()
            Me.Hide()
        Else
            MessageBox.Show("Ban Da Nhap Sai Ten Dang Nhap Hoac Mat Khau!")
        End If
    End Sub

    Private Sub btnCancle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancle.Click
        Me.Close()

    End Sub
End Class